﻿namespace Test_1
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    using com.stifel.BranchMgmtDao;
    using com.stifel.BranchPromotion;
    using com.stifel.SharePoint;

    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Linq;

    using NUnit.Framework;

    [TestFixture]
    public class UnitTest1
    {
        #region Fields

        const string currentRequestGuid = "5dfa2463-f132-4be1-aba9-af62dbfcd8e3";
        const string liveUrl = "http://win-pv542842fga:8888/sites/a725/branchsystems/brancheslive/";
        const string proposedUrl = "http://win-pv542842fga:8888/sites/a725/branchsystems/branchesproposed/";

        SPUserInfoExpanded _currentUser;

        #endregion Fields

        #region Properties

        Guid currentRequest
        {
            get
            {
                return new Guid( currentRequestGuid );
            }
        }

        SPUserInfoExpanded currentUser
        {
            get
            {
                if ( _currentUser == null )
                    _currentUser = new SPUserInfoExpanded
                    {
                        LoginName = "smallbusiness\administrator",
                        Name = "Administrator"
                    };
                return _currentUser;
            }
        }

        string targetSiteUrl
        {
            get
            {
                return proposedUrl;
            }
        }

        #endregion Properties

        #region Methods

        [Test]
        public void TestMethod1( )
        {
            using ( SPSite spSite = new SPSite( liveUrl ) )
            {
                using ( SPWeb currentWeb = spSite.OpenWeb( ) )
                {
                    BranchPromotion promotion = new BranchPromotion( currentRequest, currentUser, currentWeb, targetSiteUrl );
                    promotion.Copy( BranchPromotionArea.Info );
                }
            }
        }

        [Test]
        public void Test_BranchInfoAdd( )
        {
            using ( SPSite spSite = new SPSite( liveUrl ) )
            {
                using ( SPWeb currentWeb = spSite.OpenWeb( ) )
                {
                    StifelBranchInfoDao dao = new StifelBranchInfoDao( currentWeb.Url );
                    dao.Add( new StifelBranchInfo
                    {
                        Title = "testing"
                    } );
                }
            }
        }

        #endregion Methods
    }
}